---
title: Inspect SQL Server connection info
summary: Returns the raw credential parts and composed SQL Server connection string for a server, instance and user, without validation or caching.
status: draft
owner: Architecture
last_reviewed: 2026-10-09
operation_id: OP-06
trigger: POST /v1/Admin/GetSqlConnectionInfo
---

# OP-06: Inspect SQL Server connection info

This operation reads the secure SQL Server credential for a server, instance and user directly from the Environment API and returns the raw credential, the split user and password, and the composed connection string. It performs no probe, uses no cache and writes no audit log, and it discloses the plaintext password.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-06 |
| **Trigger** | HTTP request from an authorized caller |
| **Entry endpoint** | [`POST /v1/Admin/GetSqlConnectionInfo`](../endpoints/admin.md#post-v1-admin-getsqlconnectioninfo) |
| **Owning component** | `AdminController.GetSqlConnectionInfo`, delegating to `AdminController.GetConnectionInfo` |
| **Inputs** | Query values `server`, `instance` and `userName` (inferred query binding, no body); template `sqlconnectiontemplate` and a secure credential |
| **Outputs** | `Dictionary<string,string>` with keys `credentials`, `user`, `pw`, `connectionString` and optionally `Error` |
| **Failure response** | A failed credential split still returns 200 with an `Error` entry; a missing secure setting or template raises a failure whose status is not visible in source** |

## Steps

1. Authorize the caller against resource `DBConnAPIRetrieveResource` ([BR-DBC-025](../business-rules.md#br-dbc-025-resource-authorization-on-every-endpoint))
2. Build the lower-cased secure-setting key `sql_<server>_<instance>_<user>` ([BR-DBC-005](../business-rules.md#br-dbc-005-secure-setting-keys-are-lower-cased))
3. Read the template `sqlconnectiontemplate` and replace `{SERVER}` and `{INSTANCE}` ([BR-DBC-007](../business-rules.md#br-dbc-007-templates-come-from-the-environment-api-group))
4. Read and decrypt the secure setting directly, with no existence check, no probe and no cache ([BR-DBC-023](../business-rules.md#br-dbc-023-admin-inspection-discloses-raw-credentials))
5. Split the credential at the first pipe inside a bare `try/catch`
   - On failure: add an `Error` entry, leave `user` and `pw` empty, and continue with status 200 ([BR-DBC-024](../business-rules.md#br-dbc-024-admin-split-failure-reported-with-status-200))
6. Substitute `{USER}` and `{PW}` ([BR-DBC-008](../business-rules.md#br-dbc-008-credentials-are-substituted-into-the-template))
7. Return the dictionary with status 200

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
    A["Authorize DBConnAPIRetrieveResource"] -->|"Denied"| Z["Authorization denial, status not visible in source"]
    A --> B["Build secure key and read template"]
    B -->|"Template missing"| X["Unhandled/package error, status not visible in source"]
    B --> C["Read and decrypt secure setting"]
    C -->|"Secure setting missing or read fails"| X2["Unhandled/package error, status not visible in source"]
    C --> D{"Credential split at pipe succeeds?"}
    D -->|"Yes"| E["Set user and pw"]
    D -->|"No"| F["Add Error entry, user and pw empty"]
    E --> G["Substitute into template"]
    F --> G
    G --> H["Return dictionary, 200"]
```

## Transaction and side effects

| Aspect | Finding |
| --- | --- |
| Unit of work | None |
| Commit point | None |
| Records written | None |
| Downstream calls | SAIF Environment API through `IEnvironmentClient` |
| Repeat-call behavior | Every call re-reads the secure setting; nothing is cached |

## Logging

| Surface | Written content |
| --- | --- |
| None in this controller | `AdminController` writes no log entry, so disclosures are not audit-logged locally |

## Error handling

- Credential without a pipe: swallowed by the local `try/catch` and reported in the `Error` entry with status 200
- Missing secure setting or missing template: unhandled; handled by package middleware with a status that is not visible in source**
- Authorization failure: produced by the package authorization handler†; the status is not visible in source**

## Related documentation
- [API index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Hosting pipeline](../hosting-pipeline.md)
- [Endpoints](../endpoints.md)
- [Authentication and authorization](../authentication-authorization.md)
- [Dependencies](../dependencies.md)
- [Configuration](../configuration.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Data model](../data-model.md)
- [Operational runbook](../operational-runbook.md)
- [Tech debt](../tech-debt.md)

> **Note:** Statements marked with `†` are derived from dependency library
> documentation via the Legends CLI. Statements marked with `**` could
> not be confirmed; treat as unknown until verified.

## Sources
- DBConnectionAPI/DBConnectionAPI/Controllers/AdminController.cs
- DBConnectionAPI/DBConnectionAPI/Services/ConnectionManager.cs
- DBConnectionAPI/DBConnectionAPI/Services/IConnectionManager.cs
